<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var name = "Global";

        var obj = {
            name: "Object",
            sayName: function() {
                console.log(this.name);
            },
            innerFunction: function() {
                var inner = function() {
                    console.log(this.name);
                };
                inner();
            }
        };

        var anotherObj = {
            name: "Another Object"
        };

        obj.sayName();
        // 情况一
        //object
        obj.innerFunction();
        // 情况二
        //Global
        var sayNameBound = obj.sayName.bind(anotherObj);
        sayNameBound();
        // 情况三
        //an
        var arrowFunction = () => {
            console.log(this.name);
        };
        arrowFunction();
        // 情况四
        //gl
        var arrowFunctionInObj = {
            arrowFunction: () => {
                console.log(this.name);
            }
        };
        arrowFunctionInObj.arrowFunction();
        // 情况五
        //gl
    </script>
</body>

</html>